#include "addautoconnecttimespan.h"
#include "ui_addautoconnecttimespan.h"
#include <QTime>
#include <QMessageBox>

AddAutoConnectTimeSpan::AddAutoConnectTimeSpan(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::AddAutoConnectTimeSpan)
{
    ui->setupUi(this);
    QTime time=QTime::currentTime();
    ui->teLogin->setTime(time);
    ui->teLogout->setTime(time);
}

AddAutoConnectTimeSpan::~AddAutoConnectTimeSpan()
{
    delete ui;
}

void AddAutoConnectTimeSpan::accept()
{
    QTime t1=ui->teLogin->time();
    QTime t2=ui->teLogout->time();
    if(t1>=t2)
    {
        QMessageBox::critical(this,"错误","登录时间不在注销时间之前");
    }else{
        retstr=t1.toString("hh:mm:ss")+"-"+t2.toString("hh:mm:ss");
        QDialog::accept();
    }

}

QString AddAutoConnectTimeSpan::getRetstr() const
{
    return retstr;
}

void AddAutoConnectTimeSpan::setTime(QTime t1, QTime t2)
{
    ui->teLogin->setTime(t1);
    ui->teLogout->setTime(t2);
}
